<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>瀑布流轮播</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background: #f0f0f0;
        }

        .waterfall-carousel {
            width: 800px;
            height: 600px;
            position: relative;
            overflow: hidden;
        }

        .waterfall-container {
            position: absolute;
            width: 100%;
            height: 100%;
            display: flex;
            flex-direction: column;
            transition: transform 0.5s ease;
        }

        .waterfall-item {
            width: 100%;
            height: 200px;
            position: relative;
            overflow: hidden;
            transform-origin: center top;
            transition: all 0.5s ease;
        }

        .waterfall-item img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            transition: transform 0.5s ease;
        }

        .waterfall-item:hover img {
            transform: scale(1.1);
        }

        .controls {
            position: fixed;
            bottom: 20px;
            display: flex;
            gap: 10px;
        }

        .control-btn {
            padding: 10px 20px;
            background: #333;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            transition: background 0.3s;
        }

        .control-btn:hover {
            background: #555;
        }
    </style>
</head>
<body>
    <div class="waterfall-carousel">
        <div class="waterfall-container">
            <div class="waterfall-item">
                <img src="../img/1 (1).png" alt="Image 1">
            </div>
            <div class="waterfall-item">
                <img src="../img/1 (2).png" alt="Image 2">
            </div>
            <div class="waterfall-item">
                <img src="../img/1 (3).png" alt="Image 3">
            </div>
            <div class="waterfall-item">
                <img src="../img/1 (4).png" alt="Image 4">
            </div>
            <div class="waterfall-item">
                <img src="../img/1 (5).png" alt="Image 5">
            </div>
        </div>
    </div>
    <div class="controls">
        <button class="control-btn prev">上一张</button>
        <button class="control-btn next">下一张</button>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', () => {
            const container = document.querySelector('.waterfall-container');
            const items = document.querySelectorAll('.waterfall-item');
            const prevBtn = document.querySelector('.prev');
            const nextBtn = document.querySelector('.next');
            
            let currentIndex = 0;
            const totalItems = items.length;

            function updateCarousel() {
                const offset = -currentIndex * 200; // 200px is the height of each item
                container.style.transform = `translateY(${offset}px)`;
                
                // Add cascade effect
                items.forEach((item, index) => {
                    const distance = Math.abs(currentIndex - index);
                    const scale = Math.max(0.8, 1 - (distance * 0.1));
                    const opacity = Math.max(0.5, 1 - (distance * 0.2));
                    const zIndex = totalItems - distance;
                    
                    item.style.transform = `scale(${scale})`;
                    item.style.opacity = opacity;
                    item.style.zIndex = zIndex;
                });
            }

            prevBtn.addEventListener('click', () => {
                currentIndex = (currentIndex - 1 + totalItems) % totalItems;
                updateCarousel();
            });

            nextBtn.addEventListener('click', () => {
                currentIndex = (currentIndex + 1) % totalItems;
                updateCarousel();
            });

            // Initialize carousel
            updateCarousel();

            // Auto play
            setInterval(() => {
                currentIndex = (currentIndex + 1) % totalItems;
                updateCarousel();
            }, 3000);
        });
    </script>
</body>
</html>